#include "runner.h"
int Runner::Run(int argc, char** argv)
{
	TextFactory factory;
	try
	{
		Text & text_counter =  factory.giveText(argv[1]);
		text_counter.readText(argv[1]);
	}
	catch (const XMLException& toCatch) 
	{
		char* message = XMLString::transcode(toCatch.getMessage());
		std::cout << "Error during initialization XML parser! :\n";
		std::cout << "Exception message is: \n" << message << "\n";
		XMLString::release(&message);
		return -27;
    }
	catch(std::length_error & le)
	{
		std::cout << le.what();
		return -1;
	}
	catch(std::logic_error & le)
	{
		std::cout << le.what();
		return -2;
	}
	catch(std::ios_base::failure & iose)
	{
		std::cout << iose.what();
		return -3;
	}
	catch(...)
	{
		std::cout << "Unexpected exception...";
		return -3;
	}

	return 0;
}